﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

using JavaSubstitutes;

namespace Sprites
{
	public class CoinAnim: Sprite
	{
		private int life = 10;

		public CoinAnim(int xTile, int yTile)
		{
			sheet = Art.level;
			wPic = hPic = 16;

			x = xTile * 16;
			y = yTile * 16 - 16;
			xDelta = 0;
			yDelta = -6f;
			xPic = 0;
			yPic = 2;
		}

		public override void move()
		{
			if (life-- < 0)
			{
				Sprite.spriteContext.removeSprite(this);
				for (int xx = 0; xx < 2; xx++)
					for (int yy = 0; yy < 2; yy++)
						Sprite.spriteContext.addSprite(new Sparkle((int)x + xx * 8 + (int)(RandomExtensions.random() * 8), (int)y + yy * 8 + (int)(RandomExtensions.random() * 8), 0, 0, 0, 2, 5));
			}

			xPic = life & 3;

			x += xDelta;
			y += yDelta;
			yDelta += 1;
		}
	}
}